<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Paymenthistory_model extends CI_Model {

	function __construct() {
		parent::__construct();
		
	}

	/**
	 * 회원의 결제 내역
	 */
	function select_payment_history_list($user_id, $page_no, $page_size) {
		log_message('debug',"#### Paymenthistory_model::get_payment_history($user_id)");

		$start_row = ($page_no-1) * $page_size;

		$sql  = PHP_EOL." SELECT ";
		$sql .= PHP_EOL."       P.user_id ";
		$sql .= PHP_EOL."     , P.pname ";
		$sql .= PHP_EOL."     , P.pltid ";
		$sql .= PHP_EOL."     , P.pgcode ";
		$sql .= PHP_EOL."     , P.amt ";
		$sql .= PHP_EOL."     , P.txdate ";
		$sql .= PHP_EOL."     , P.txtime ";
		$sql .= PHP_EOL."     , P.create_dt ";
		$sql .= PHP_EOL." FROM  tb_payment_history P ";
		$sql .= PHP_EOL." WHERE P.user_id = ? ";
		$sql .= PHP_EOL." ORDER BY P.create_dt DESC ";
		$sql .= PHP_EOL." LIMIT $start_row, $page_size ";
		$query = $this->db->query($sql, array($user_id)) or $this->logsql->log_sql('error');
		$this->total_count = $this->db->count_all_results();
		$result = $query->result_array();
		
		$this->logsql->log_sql();
		$this->logsql->log_result($result);

		return $result;
	}
	
	/**
	 * 총 글 수
	 */
	function get_payment_history_total_count($user_id) {
		$this->db->where('user_id', $user_id);
		$this->db->from('tb_payment_history');
		$result = $this->db->count_all_results();

		$this->logsql->log_sql();
		$this->logsql->log_result($result);

		return $result;
	}
}

/* End of file paymenthisotory_model.php */
/* Location: ./application/models/mypage/paymenthisotory_model.php */